<?php

require_once('inc/addons.php');
require_once('inc/users.php');
require_once('inc/functions.php');

Users::startSession();

$types = array('plugin' => 'Plugins', 'action' => 'Action Packs', 'theme' => 'Themes');

define('SUBPAGE', 'home');
showHeader();
?>
    <h2>Welcome</h2>
    <p>
     Welcome to the DMDirc addons directory. This site lists all known addons
     for <a href="http://www.DMDirc.com/">DMDirc</a> (an open-source IRC client).
     Addons may be packs of 'actions' (small script-like files that make DMDirc
     respond to certain events), plugins (compiled code that adds new
     functionality to the client), or themes (collections of UI settings and
     formatters that change the look of the client).
    </p>
    <p>
     You can browse the addons using the menu on the left, or see a selection
     of some of the latest and best addons below.
    </p>
    <h2 style="margin-bottom: 0px; padding-top: 10px;">Most popular...</h2>
<?php

 foreach ($types as $type => $text) {
 	?>
    <div style="float: left; width: 33%;">
     <h3><?php echo $text; ?></h3>
     <ol>
<?php

foreach (Addons::getTopAddons($type) as $addon) {
	echo '<li>' . $addon->buildLink() . '</li>';
}

?>
     </ol>
    </div>
<?php
 }
?>
    <h2 style="clear: both; margin-bottom: 0px; padding-top: 10px;">Most recently added/updated...</h2>
<?php

 foreach ($types as $type => $text) {
 	?>
    <div style="float: left; width: 33%;">
     <h3><?php echo $text; ?></h3>
     <ol>
<?php

foreach (Addons::getRecentAddons($type) as $addon) {
	echo '<li>' . $addon->buildLink() . '</li>';
}

?>
     </ol>
    </div>
<?php
 }
	showFooter();
?>
